local zishucup__furen = fk.CreateSkill{
  name = "zishucup__furen",
}

Fk:loadTranslationTable{
  ["zishucup__furen"] = "敷衽",
  [":zishucup__furen"] = "弃牌阶段，你可以改为执行摸牌阶段；若如此做，你不能使用【闪】以外的牌，直到你受到伤害或失去牌后。",

  ["@@zishucup__furen"] = "敷衽 禁用非闪",

  ["$zishucup__furen1"] = " ",
  ["$zishucup__furen2"] = " ",
}

zishucup__furen:addEffect(fk.EventPhaseChanging, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(zishucup__furen.name) and data.phase == Player.Discard and target == player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:sendLog{
      type = "#PhaseChanged",
      from = player.id,
      arg = Util.PhaseStrMapper(data.phase),
      arg2 = "phase_draw",
    }
    room:setPlayerMark(player, "@@zishucup__furen", 1)
    data.phase = Player.Draw
  end,
})

local spec = {
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@zishucup__furen", 0)
  end,
}

zishucup__furen:addEffect(fk.Damaged, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@@zishucup__furen") > 0
  end,
  on_refresh = spec.on_refresh,
})

zishucup__furen:addEffect(fk.AfterCardsMove, {
  can_refresh = function(self, event, target, player, data)
    if player:getMark("@@zishucup__furen") > 0 then
      for _, move in ipairs(data) do
        if move.from == player then
          for _, info in ipairs(move.moveInfo) do
            return info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip
          end
        end
      end
    end
  end,
  on_refresh = spec.on_refresh,
})

zishucup__furen:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    if player:getMark("@@zishucup__furen") > 0 then
      return card.trueName ~= "jink"
    end
  end,
})

return zishucup__furen
